package com.wf.smartcomm.server.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wf.smartcomm.server.bean.Video;
import com.wf.smartcomm.server.service.VideoService;
import com.wf.smartcomm.server.util.IdUtils;

/** 
 * @author 38884306@qq.com  
 * @version 创建时间：2015-5-25 上午10:17:20 
 * 
 */
@Service
@Transactional
public class VideoServiceImpl implements VideoService {

	@Resource
	private SessionFactory factory;
	
	@Override
	public void save(Video video) {
		video.setObjectId(IdUtils.uuid());
		video.setCreatedAt(String.valueOf(System.currentTimeMillis()));
		factory.getCurrentSession().persist(video);
	}

	@Override
	public void save(List<Video> videos) {
		for (Video video : videos) {
			video.setObjectId(IdUtils.uuid());
			video.setCreatedAt(String.valueOf(System.currentTimeMillis()));
			factory.getCurrentSession().persist(video);
		}
	}

}
